build:
	docker build -t httpserver .

push:
	docker tag httpserver:latest registry.cn-shenzhen.aliyuncs.com/lc-docker/httpserver:v1.0
	docker push registry.cn-shenzhen.aliyuncs.com/lc-docker/httpserver:v1.0

run:
	docker run --name httpserver -d -p 80:80 httpserver

create secret:
kubectl create secret docker-registry ali  --docker-username=xxxx --docker-password=xxx --docker-server=https://registry.cn-shenzhen.aliyuncs.com

create ConfigMap:
kubectl apply -f ConfigMap.yml

create Deployment:
kubectl apply -f deployment.yml

create Service:
kubectl apply -f svc.yml

access pod:
kubectl get pod -o wide
NAME                                     READY   STATUS    RESTARTS   AGE     IP               NODE        NOMINATED NODE   READINESS GATES
http-deployment-5ddbff8868-vpsc5         1/1     Running   0          2m32s   10.244.169.164   k8s-node2   <none>           <none>

[root@k8s-master module-8]# curl 10.244.169.164
请求成功，请在终端查看！

[root@k8s-master module-8]# curl 10.244.169.164/healthz
200
access svc:
[root@k8s-master module-8]# kubectl get svc -o wide
NAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE     SELECTOR
httpserver      ClusterIP   10.107.33.76    <none>        80/TCP         5m43s   app=httpserver

[root@k8s-master module-8]# kubectl get ep
NAME                                          ENDPOINTS                             AGE
httpserver                                    10.244.169.164:80                     6m4s
[root@k8s-master module-8]# curl 10.107.33.76
请求成功，请在终端查看！
[root@k8s-master module-8]# curl 10.107.33.76/healthz
200

部署nginx ingress-controller:
kubectl apply -f ingress-controller.yaml

create ingress rule:
kubectl apply -f ingress.yml

Ingress配置tls访问:
创建证书文件：
cat > go.demo.com-csr.json <<EOF
{
  "CN": "nginx.demo.com",
  "hosts": [],
  "key": {
    "algo": "rsa",
    "size": 2048
  },
  "names": [
    {
      "C": "CN",
      "L": "BeiJing",
      "ST": "BeiJing"
    }
  ]
}
EOF

使用根证书和私钥签名生成目标证书和私钥:
# cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes go.demo.com-csr.json | cfssljson -bare go.demo.com

将证书保存到Secret中:
kubectl create secret tls go-tls --cert=/tls/go.demo.com.pem --key=/tls/go.demo.com-key.pem






